//
//  ArrayDataSource.h
//  Castlery
//
//  Created by xie weizhi on 8/8/17.
//  Copyright © 2017 xie weizhi. All rights reserved.
//

#import <UIKit/UIKit.h>

/**
 Called when need to configure the cell.
 */
typedef void (^CellConfigureBlock)(id parentView, id cell, id item, NSIndexPath *indexPath);

/**
 Called when create collection/table cell.
 */
typedef id (^CellCreationBlock)(id parentView, id item, NSIndexPath *indexPath);


@interface ArrayDataSource : NSObject <UITableViewDataSource>

@property (nonatomic, copy) CellConfigureBlock cellConfigureBlock;
@property (nonatomic, copy) CellCreationBlock cellCreationBlock;
@property (nonatomic, copy) NSArray *items; ///< objects used to configure the cells.

- (instancetype)initWithItems:(NSArray *)items;

///< return an item with a given indexPath.
- (id)itemAtIndexPath:(NSIndexPath *)indexPath;

///< append items to the end of the collectionn view.
- (void)appendItems:(NSArray *)newItems;


@end
